home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.2 / IFF / PGTB / catch.asm next >
Encoding:
Assembly Source File  |  1992-08-27  |  18.8 KB  |  727 lines

  1. *
  2. * catch.asm
  3. * Replacement Lattice startup module with PGTB catcher
  4. *
  5. *
  6.     nolist
  7.     INCLUDE "exec/types.i"
  8.     INCLUDE "exec/alerts.i"
  9.     INCLUDE "exec/nodes.i"
  10.     INCLUDE "exec/lists.i"
  11.     INCLUDE "exec/ports.i"
  12.     INCLUDE "exec/libraries.i"
  13.     INCLUDE "exec/tasks.i"
  14.     INCLUDE "exec/execbase.i"
  15.     INCLUDE "libraries/dos.i"
  16.     INCLUDE "libraries/dosextens.i"
  17.     INCLUDE "workbench/startup.i"
  18.     INCLUDE    "intuition/intuition.i"
  19.     INCLUDE "exec/exec_offsets.i"
  20.     INCLUDE    "intuition/intuition_offsets.i"
  21.     INCLUDE "libraries/dos_offsets.i"
  22.     list
  23.  
  24.     ifd    CAPE
  25.     CSYMFMT
  26.     endc
  27.  
  28. VERSION     equ    1
  29. REVISION    equ    5
  30. VBlankOffset    equ    $212        ; necessary until I figure what
  31.                     ; the heck is going on
  32.  
  33.     xdef    XCEXIT            ; exit(code) is standard way to leave C.
  34.  
  35.     xref    LinkerDB        ; linker defined base value
  36.     xref    _BSSBAS         ; linker defined base of BSS
  37.     xref    _BSSLEN         ; linker defined length of BSS
  38.  
  39. *    library references
  40.  
  41.     xref    _main            ; Name of C program to start with.
  42.     xref    MemCleanup
  43.  
  44. start:
  45.     movem.l d1-d6/a0-a6,-(a7)
  46. REGSIZE EQU    (6+7)*4
  47.     lea    REGSIZE(a7),A5          ; determine old stack pointer
  48.     move.l    a0,a2            ; save command pointer
  49.     move.l    d0,d2            ; and command length
  50.     lea    LinkerDB,a4        ; load base register
  51.  
  52.     move.l    _AbsExecBase,a6
  53.     move.l    a6,SysBase(A4)
  54.     move.w    AttnFlags(a6),Environment+2(a4) ; save copy for dump
  55.     move.l    a7,_StackPtr(A4)        ; Save stack ptr
  56.     clr.l    WBenchMsg(A4)
  57.  
  58. *------ attempt to open Intuition library:
  59.     bsr    openIntui
  60.  
  61. *------ attempt to open DOS library:
  62.     bsr    openDOS
  63.  
  64. *------ get the address of our task
  65.     suba.l    a1,a1
  66.     Call    FindTask
  67.     move.l    d0,a3
  68.  
  69. *------ initialize exception handler
  70.     move.l    #Exception,TC_TRAPCODE(a3)      ; install pointer
  71.  
  72. *------ are we running as a son of Workbench?
  73.     move.l    pr_CurrentDir(A3),curdir(A4)
  74.     tst.l    pr_CLI(A3)
  75.     beq.s    fromWorkbench
  76.  
  77. *=======================================================================
  78. *====== CLI Startup Code ===============================================
  79. *=======================================================================
  80. *
  81. * Entry: D2 = command length
  82. *     A2 = Command pointer
  83. fromCLI:
  84.     moveq    #-1,d0
  85.     move.l    d0,Starter(a4)          ; non-zero means CLI
  86.     move.l    a5,D0            ; get top of stack
  87.     move.l    d0,StackTop(a4)         ; ..(save a copy)
  88.     sub.l    4(a5),D0                ; compute bottom
  89.     add.l    #128,D0         ; allow for parms overflow
  90.     move.l    D0,_base(A4)            ; save for stack checking
  91.  
  92. *------ find command name:
  93.     move.l    pr_CLI(a3),a0
  94.     add.l    a0,a0            ; bcpl pointer conversion
  95.     add.l    a0,a0
  96.     move.l    cli_CommandName(a0),a1
  97.     add.l    a1,a1            ; bcpl pointer conversion
  98.     add.l    a1,a1
  99.  
  100. *------ collect parameters:
  101.     move.l    d2,d0            ; get command line length
  102.     moveq.l #0,d1
  103.     move.b    (a1)+,d1
  104.     move.l    a1,_ProgramName(A4)
  105.     add.l    d1,d0            ; add length of command name
  106.     addq.l    #1,d0            ; allow for space after command
  107.  
  108.     clr.w    -(A7)                   ; set null terminator for command line
  109.     addq.l    #1,D0            ; force to even number of bytes
  110.     andi.w    #$fffe,D0        ;(round up)
  111.     sub.l    D0,A7            ; make room on stack for command line
  112.     subq.l    #2,D0
  113.     clr.w    0(A7,D0)
  114.  
  115. *------ copy command line onto stack
  116.     move.l    d2,d0            ; get command line length
  117.     subq.l    #1,d0
  118.     add.l    d1,d2
  119.  
  120. copy_line:
  121.     move.b    0(A2,D0.W),0(A7,D2.W)   ; copy command line to stack
  122.     subq.l    #1,d2
  123.     dbf    d0,copy_line
  124.     move.b    #' ',0(a7,d2.w)         ; add space between command and parms
  125.     subq.l    #1,d2
  126.  
  127. copy_cmd
  128.  
  129.     move.b    0(a1,d2.w),0(a7,d2.w)   ; copy command name to stack
  130.     dbf    d2,copy_cmd
  131.     move.l    A7,A1
  132.     move.l    A1,-(A7)                ; push command line address
  133.     bra.s    goto_main        ; call C entrypoint
  134.  
  135. *=======================================================================
  136. *====== Workbench Startup Code =========================================
  137. *=======================================================================
  138.  
  139. fromWorkbench:
  140.     move.l    TC_SPLOWER(a3),_base(A4)        ; set base of stack
  141.     add.l    #128,_base(A4)          ; allow for parms overflow
  142.     move.l    TC_SPUPPER(a3),StackTop(a4)     ; set top of stack
  143.  
  144. *------ we are now set up.  wait for a message from our starter
  145.     bsr    waitmsg
  146.     move.l    d0,WBenchMsg(a4)
  147.     move.l    d0,-(SP)
  148. *
  149.     move.l    d0,a2            ; get first argument
  150.     move.l    sm_ArgList(a2),d0
  151.     beq.s    do_cons
  152.     move.l    DOSBase(a4),a6
  153.     move.l    d0,a0
  154.     move.l    wa_Lock(a0),d1
  155.     move.l    d1,curdir(A4)
  156.     Call    CurrentDir
  157. do_cons:
  158.     move.l    sm_ToolWindow(a2),d1    ; get the window argument
  159.     beq.s    do_main
  160.     move.l    #MODE_OLDFILE,d2
  161.     Call    Open
  162.     move.l    d0,stdin(a4)
  163.     beq.s    do_main
  164.     lsl.l    #2,d0
  165.     move.l    d0,a0
  166.     move.l    fh_Type(a0),pr_ConsoleTask(A3)
  167. do_main:
  168.     move.l    WBenchMsg(A4),a0        ; get address of workbench message
  169.     move.l    a0,-(a7)                ; push argv
  170.     pea    NULL(a4)                ; push argc
  171.     move.l    sm_ArgList(a0),a0       ; get address of arguments
  172.     move.l    wa_Name(a0),_ProgramName(A4)    ; get name of program
  173.  
  174. *=============================================
  175. *------ common code --------
  176. *=============================================
  177.  
  178. goto_main:
  179.     lea    _BSSBAS,a3        ; get base of BSS
  180.     moveq    #0,d1
  181.     move.l    #_BSSLEN,d0        ; get length of BSS in longwords
  182.     bra.s    clr_lp            ; and clear for length given
  183. clr_bss move.l    d1,(a3)+
  184. clr_lp    dbf    d0,clr_bss
  185. main    jsr    _main(PC)               ; call C entrypoint
  186.     moveq.l #0,d0            ; set successful status
  187.     bra.s    exit2
  188. *
  189.  
  190. XCEXIT:
  191.     move.l    4(SP),d0                ; extract return code
  192. exit2:
  193.     move.l    d0,-(a7)
  194.     move.l    _ONEXIT(A4),d0          ; exit trap function?
  195.     beq.s    exit3
  196.     move.l    d0,a0
  197.     jsr    (a0)
  198. exit3:
  199.     jsr    MemCleanup(PC)          ; cleanup leftover memory alloc.
  200.     move.l    _AbsExecBase,a6
  201.     move.l    DOSBase(A4),a1
  202.     Call    CloseLibrary        ; close DOS library
  203.  
  204.     move.l    IntuiBase(a4),a1
  205.     Call    CloseLibrary        ; close Intuition library
  206.  
  207.     tst.l    MathBase(A4)
  208.     beq.s    done_1a
  209.     move.l    MathBase(a4),a1
  210.     Call    CloseLibrary        ; close ffp math library
  211.  
  212. done_1a:
  213.     tst.l    MathTransBase(A4)
  214.     beq.s    done_1b
  215.     move.l    MathTransBase(a4),a1
  216.     Call    CloseLibrary        ; close ffp transcendental
  217.  
  218. done_1b:
  219.     tst.l    MathIeeeDoubBasBase(A4)
  220.     beq.s    done_1c
  221.     move.l    MathIeeeDoubBasBase(A4),a1
  222.     Call    CloseLibrary        ; close Amiga IEEE library
  223.  
  224. done_1c:
  225. *------ if we ran from CLI, skip workbench cleanup:
  226.     tst.l    WBenchMsg(A4)
  227.     beq.s    exitToDOS
  228.     move.l    console_dev(A4),d1
  229.     beq.s    done_2
  230.     Call    Close
  231. done_2:
  232.     move.l    stdin(a4),d1
  233.     beq.s    done_4
  234.     Call    Close
  235. done_4:
  236.  
  237. *------ return the startup message to our parent
  238. *    we forbid so workbench can't UnLoadSeg() us
  239. *    before we are done:
  240.     move.l    _AbsExecBase,A6
  241.     Call    Forbid
  242.     move.l    WBenchMsg(a4),a1
  243.     Call    ReplyMsg
  244.  
  245. *------ this rts sends us back to DOS:
  246. exitToDOS:
  247.     MOVE.L    (A7)+,D0
  248.     movea.l _StackPtr(a4),SP        ; restore stack ptr
  249.     movem.l (a7)+,d1-d6/a0-a6
  250.     rts
  251.  
  252. *-----------------------------------------------------------------------
  253. noDOS:
  254.         moveq.l #100,d0
  255.         bra    exit2
  256.  
  257.  
  258. *-----------------------------------------------------------------------
  259. * This routine gets the message that workbench will send to us
  260. * called with task id in A3
  261.  
  262. waitmsg:
  263.         lea    pr_MsgPort(A3),a0       ; our process base
  264.         Call    WaitPort
  265.         lea    pr_MsgPort(A3),a0       ; our process base
  266.         Call    GetMsg
  267.         rts
  268.  
  269. *-----------------------------------------------------------------------
  270. *  Open the DOS library:
  271.  
  272. openDOS:
  273.         lea    DOSName(A4),A1
  274.         moveq.l #0,D0
  275.         Call    OpenLibrary
  276.         move.l    D0,DOSBase(A4)
  277.         beq    noDOS
  278.         rts
  279.  
  280. *-----------------------------------------------------------------------
  281. *  Open the Intuition library:
  282.  
  283. openIntui:
  284.         lea    IntuiName(A4),A1
  285.         moveq.l #0,D0
  286.         Call    OpenLibrary
  287.         move.l    D0,IntuiBase(A4)
  288.         beq    noDOS
  289.         rts
  290.  
  291. *-----------------------------------------------------------------------
  292. *  The Exception Handler - catches GURUs and exits (semi)cleanly
  293. Exception:
  294.     move.l    (a7)+,d0                ; get exception # from stack
  295.     move.l    d0,GURUNum        ; and save it
  296.     cmpi.l    #3,d0            ; ADDRESS or BUS error?
  297.     bgt.s    2$            ; no, skip adjustment
  298.     btst    #0,Environment+3    ; is it 68010 or 68020?
  299.     beq.s    1$            ; 0 means NO
  300.     bset    #7,8(a7)                ; set Rerun flag
  301.     bra.s    2$
  302. 1$:
  303.     addq.l    #8,a7            ; adjust for 68000
  304. 2$:
  305.     move.l    2(a7),d0                ; get PC at crash
  306.     move.l    d0,GURUAddr        ; and save it
  307.     move.l    #GURUExit,2(a7)         ; use our own exit point
  308.     rte
  309.  
  310. *-----------------------------------------------------------------------
  311. *  The Exception exit routine - write 'PGTB' IFF chunk to file
  312. *  'SnapShot.TB' in current directory, then exit to system.
  313.  
  314. GURUExit:
  315.     movem.l d0-d7/a0-a7,DDump    ; save all registers
  316.     move.l    _AbsExecBase,a6     ; make sure we are working with Exec
  317.     Call    GetCC            ; safe way - works with all CPUs
  318.     lea    LinkerDB,a4        ; make sure we have a valid # in a4
  319.     move.l    d0,Flags(a4)            ; save area
  320.     tst.l    StackPtr(a4)        ; if there's something there
  321.     bne    998$            ; ...we've been here before!
  322.     lea    TempStore(a4),a0    ; calculate addr of TempStore
  323.     move.l    a0,TempAddr(a4)        ; ...and save for later access
  324.     move.l    A7Store(a4),d0          ; make sure we have proper TOS
  325.     move.l    d0,StackPtr(a4)         ; ...and save it
  326.     moveq    #0,d0
  327.     move.l    _ProgramName(a4),a0     ; find length of program name
  328.     move.l    a0,PName(a4)
  329.     subq.l    #1,a0
  330.     move.b    (a0),d0
  331.     addq.l    #4,d0            ; adjust for shift
  332.     lsr.l    #2,d0
  333.     move.l    d0,NameLen(a4)          ; store length
  334.     add.l    d0,FAILlen(a4)          ; and sub-chunk total
  335.  
  336.     moveq    #0,d0            ; clear d0 for use
  337.     lea    VBlankOffset(a6),a0     ; set up a0 to find correct data
  338.     move.b    (a0)+,d0                ; get just in case
  339.     move.l    d0,VBlankFreq(a4)       ; ...so we can figure what
  340.     move.b    (a0),d0                 ; ...type of machine
  341.     move.l    d0,PowerSupFreq(a4)    ; ...we're working on
  342.  
  343.     lea    start-4(pc),a0          ; get seglist ptr
  344.     moveq    #-1,d0            ; always at least 1
  345. 2$:
  346.     addq.l    #1,d0
  347.     move.l    (a0),d1                 ; find end of list
  348.     beq.s    3$
  349.     lsl.l    #2,d1            ; BPTR!!!!!
  350.     move.l    d1,a0
  351.     bra.s    2$
  352. 3$:
  353.     add.l    d0,SegCount(a4)         ; store # of seglist pointers
  354.     lsl.l    #1,d0            ; multiply by 2 for longword count
  355.     add.l    d0,FAILlen(a4)          ; and sub-chunk length
  356.  
  357.     move.l    StackTop(a4),d0         ; get top of stack
  358.     sub.l    StackPtr(a4),d0         ; find number of bytes used
  359.     addq.l    #4,d0            ; adjust for longword conversion
  360.     lsr.l    #2,d0            ; convert from bytes to long
  361.     move.l    d0,StackLen(a4)         ; and save
  362.     add.l    d0,s2len(a4)            ; and sub-chunk total
  363.  
  364.     moveq    #0,d0            ; PosFlag
  365.     move.l    d0,d1            ; NegFlag
  366.     move.l    d0,a0            ; 0 means use current window
  367.     lea    IText1(a4),a1           ; Body Text
  368.     lea    IText5(a4),a2           ; Positive Gadget Text
  369.     lea    IText6(a4),a3           ; Negative Gadget Text
  370.     moveq    #1,d2
  371.     lsl.l    #8,d2            ; quick way to set Width
  372.     moveq    #76,d3            ; Height
  373.     move.l    IntuiBase(a4),a6    ; get intuition library pointer
  374.     Call    AutoRequest
  375.     move.l    _AbsExecBase,a6
  376.     tst.l    d0            ; save SnapShot?
  377.     beq    999$            ; no, just exit
  378.  
  379.     move.l    DOSBase(a4),a6
  380.     lea    DumpName(a4),a0         ; get name of output file
  381.     move.l    a0,d1
  382.     move.l    #MODE_NEWFILE,d2    ; create new file
  383.     Call    Open
  384.     bne.s    4$
  385.     lea    DumpPath(a4),a0         ; if error in current dir, try RAM:
  386.     move.l    a0,d1
  387.     move.l    #MODE_NEWFILE,d2
  388.     Call    Open
  389.     beq    8$            ; if error now, nothing to do but die
  390. 4$:
  391.     move.l    d0,d5            ; save file handle for Write
  392.     move.l    d0,fp(a4)        ; ...and in a safe place for later
  393.     move.l    d5,d1            ; get file handle
  394.     lea    PGTB(a4),a0             ; first part of fixed
  395.     move.l    a0,d2
  396.     move.l    #chunk_len_1,d3     ; length of first
  397.     Call    Write
  398.  
  399.     move.l    d5,d1            ; get file handle
  400.     move.l    _ProgramName(a4),d2     ; get address of program name
  401.     move.l    NameLen(a4),d3          ; get # longs in program name
  402.     lsl.l    #2,d3            ; ..and convert to bytes
  403.     Call    Write
  404.  
  405.     move.l    d5,d1            ; get file handle
  406.     lea    Environment(a4),a0      ; second part of fixed
  407.     move.l    a0,d2
  408.     move.l    #chunk_len_2,d3     ; length of second part
  409.     Call    Write
  410.  
  411.     lea    start-8(pc),a0        ; address of seglist (size of seg)
  412.     move.l    (a0)+,d0        ; segsize
  413.     move.l    d0,TempStore+4(a4)    ; save it
  414.     move.l    a0,TempStore(a4)    ; store first number
  415.     move.l    SegCount(a4),d4
  416. 5$:
  417.     move.l    d5,d1            ; get file handle
  418.     move.l    TempAddr(a4),d2        ; address of write buffer
  419.     moveq    #TempSize,d3        ; size of segment pointer
  420.     Call    Write
  421.     move.l    TempStore(a4),a0    ; retrieve pointer
  422.     move.l    (a0),d0            ; get next seg pointer
  423.     lsl.l    #2,d0            ; adjust
  424.     move.l    d0,TempStore(a4)    ; ..and save
  425.     move.l    d0,a0
  426.     move.l    -4(a0),d0        ; get segsize
  427.     move.l    d0,TempStore+4(a4)    ; ...and save it
  428.     subq.l    #1,d4            ; done yet?
  429.     bne.s    5$            ; no, do next
  430.  
  431.     move.l    d5,d1            ; (get the idea?)
  432.     lea    subREGS(a4),a0          ; third part of fixed
  433.     move.l    a0,d2
  434.     move.l    #chunk_len_3,d3     ; length of third
  435.     Call    Write
  436.  
  437.     move.l    StackLen(a4),d0        ; get length of stack used
  438.     cmpi.l    #8192,d0        ; > 8k ?
  439.     bgt.s    6$            ; yes, dump two chunks
  440.     move.l    d5,d1
  441.     lea    STAK2(a4),a0            ; whole stack chunk
  442.     move.l    a0,d2
  443.     moveq    #STAK2len,d3        ; length of fixed part
  444.     Call    Write
  445.  
  446.     move.l    d5,d1
  447.     move.l    StackPtr(a4),d2         ; address of stack
  448.     move.l    StackLen(a4),d3         ; # longwords on stack
  449.     lsl.l    #2,d3            ; ..converted to bytes
  450.     Call    Write
  451.     bra.s    8$
  452. 6$:
  453.     move.l    d5,d1
  454.     lea    STAK3(a4),a0        ; top4k chunk
  455.     move.l    a0,d2
  456.     moveq    #STAK3len,d3        ; length of fixed part
  457.     Call    Write
  458.  
  459.     move.l    d5,d1
  460.     move.l    StackTop(a4),d2        ; find top of stack
  461.     sub.l    #4096,d2        ; find top-4k
  462.     move.l    #4096,d3        ; # bytes to write
  463.     Call    Write
  464.  
  465.     move.l    d5,d1
  466.     lea    STAK4(a4),a0        ; bottom4k chunk
  467.     move.l    a0,d2
  468.     moveq    #STAK4len,d3        ; length of fixed part
  469.     Call    Write
  470.  
  471.     move.l    d5,d1
  472.     move.l    StackPtr(a4),d2        ; current stack address
  473.     move.l    #4096,d3        ; # bytes to write
  474.     Call    Write
  475. 8$:
  476.     tst.l    _ONGURU(A4)        ; user GURU function?
  477.     beq.s    9$
  478.     move.l    d5,-(sp)
  479.     move.l    d5,d1
  480.     lea    UDAT(a4),a0
  481.     move.l    a0,d2
  482.     move.l    #UDATlen,d3
  483.     Call    Write
  484.     move.l    d5,d1
  485.     moveq    #0,d2            ; zero offset
  486.     moveq    #1,d3            ; ...from EOF
  487.     Call    Seek
  488.     move.l    d0,SeekStore(a4)
  489.     move.l    _ONGURU(a4),a0
  490.     jsr    (a0)
  491.     addq.l    #4,sp
  492. 9$:
  493.     move.l    fp(a4),d5
  494.     move.l    d5,d1
  495.     moveq    #0,d2            ; offset from EOF
  496.     moveq    #1,d3            ; OFFSET_END
  497.     Call    Seek            ; Seek returns OLD position
  498.     move.l    d0,d1
  499.     andi.l    #3,d1            ; did user write even longwords?
  500.     beq.s    10$            ; Yep!  Nice Human.
  501.     move.l    d1,d6            ; Nope, save for later.
  502.     clr.l    TempStore(a4)        ; clear temp storage
  503.     move.l    d5,d1
  504.     move.l    TempAddr(a4),d2
  505.     moveq    #4,d3
  506.     sub.l    d6,d3            ; find how many NULLs to pad
  507.     Call    Write
  508.     bra.s    9$
  509. 10$:
  510.     move.l    d0,TempStore+4(a4)    ; save file length
  511.     tst.l    SeekStore(a4)        ; did we write UDAT?
  512.     beq.s    11$            ; nope!
  513.     sub.l    SeekStore(a4),d0    ; find length of UDAT section
  514.     lsr.l    #2,d0            ; adjust to longwords
  515.     move.l    d0,TempStore(a4)    ; save UDAT length for write
  516.     move.l    d5,d1
  517.     move.l    SeekStore(a4),d2    ; find where to write it
  518.     subq.l    #4,d2
  519.     moveq    #-1,d3            ; OFFSET_BEGINNING
  520.     Call    Seek
  521.     move.l    d5,d1
  522.     move.l    TempAddr(a4),d2
  523.     move.l    #4,d3
  524.     Call    Write            ; write length of UDAT field to file
  525. 11$:
  526.     move.l    d5,d1
  527.     moveq    #4,d2            ; offset to 'Length' field
  528.     moveq    #-1,d3            ; OFFSET_BEGINNING
  529.     Call    Seek
  530.     move.l    TempStore+4(a4),d0    ; get file length back
  531.     subq.l    #8,d0            ; adjust total length
  532.     lsr.l    #2,d0            ; adjust to longwords
  533.     move.l    d0,TempStore(a4)    ; save for write
  534.     move.l    d5,d1
  535.     move.l    TempAddr(a4),d2
  536.     move.l    #4,d3
  537.     Call    Write            ; write 'Length' field
  538. 998$:
  539.     move.l    fp(a4),d1
  540.     beq.s    999$
  541.     move.l    DOSBase(a4),a6
  542.     Call    Close
  543. 999$:
  544.     move.l    _AbsExecBase,a6
  545.     move.l    #999,d0
  546.     bra    exit2
  547.  
  548.     section _MERGED,DATA
  549. *
  550.     xdef    NULL,SysBase,LoadAddress,console_dev,WBenchMsg,DOSBase
  551.     xdef    curdir,_mbase,_mnext,_msize,_tsize
  552.     xdef    _oserr,_OSERR,_FPERR,_SIGFPE,_ONERR,_ONEXIT,_ONBREAK,_ONGURU
  553.     xdef    _SIGINT,_ECS
  554.     xdef    _ProgramName,_StackPtr,_base
  555.     xdef    MathIeeeDoubBasBase
  556. *
  557. NULL        dc.l    0        ;
  558. _mbase        dc.l    0        ; base of memory pool
  559. _mnext        dc.l    0        ; next available memory location
  560. _msize        dc.l    0        ; size of memory pool
  561. _tsize        dc.l    0        ; total size?
  562. _base        dc.l    0        ; base of stack
  563. _StackPtr    dc.l    0
  564. _oserr:
  565. _OSERR        dc.l    0
  566. _FPERR        dc.l    0
  567. _SIGFPE     dc.l    0
  568. _SIGINT     dc.l    0
  569. _ONERR        dc.l    0
  570. _ONEXIT     dc.l    0
  571. _ONBREAK    dc.l    0
  572. _ONGURU        dc.l    0
  573. _ECS        dc.l    0        ; extended character set flag
  574. curdir        dc.l    0
  575. console_dev    dc.l    0
  576. SysBase     dc.l    0
  577. LoadAddress    dc.l    0        ; program load address
  578. WBenchMsg    dc.l    0
  579. stdin        dc.l    0
  580. _ProgramName    dc.l    0
  581. DOSBase     dc.l    0
  582. IntuiBase    dc.l    0
  583. MathBase    dc.l    0
  584. MathTransBase    dc.l    0
  585. MathIeeeDoubBasBase dc.l       0
  586. DOSName     dc.b    'dos.library',0
  587. IntuiName    dc.b    'intuition.library',0
  588. fp        dc.l    0        ; save SnapShot file pointer
  589. DumpPath    dc.b    'RAM:'
  590. DumpName    dc.b    'SnapShot.TB',0
  591. SeekStore    dc.l    0
  592. TempAddr    dc.l    0        ; Storage for &TempStore
  593. TempStore    dc.l    0,0        ; Temporary storage for BPTR -> APTR
  594. TempSize    equ    *-TempStore
  595.  
  596. TAttr:                ; Text attributes for font
  597.     dc.l    TName        ; name of font
  598.     dc.w    TOPAZ_EIGHTY    ; font size
  599.     dc.b    FS_NORMAL    ; font style
  600.     dc.b    0        ; font preferences
  601. TName:
  602.     dc.b    'topaz',0
  603.  
  604. IText1:                ; Text definitions for AutoReq call
  605.     dc.b    3,0,RP_JAM1,0    ; front & back pens, drawmode and filler byte
  606.     dc.w    6,4        ; XY origin relative to container TopLeft
  607.     dc.l    TAttr        ; font pointer or NULL for default
  608.     dc.l    ITextText1    ; pointer to text
  609.     dc.l    IText2        ; next IntuiText structure
  610. ITextText1:
  611.     dc.b    'Program:',0
  612.     cnop 0,2
  613. IText2:
  614.     dc.b    3,0,RP_JAM1,0
  615.     dc.w    78,4
  616.     dc.l    TAttr
  617. PName    dc.l    0
  618.     dc.l    IText3
  619.     cnop    0,2
  620. IText3:
  621.     dc.b    3,0,RP_JAM1,0
  622.     dc.w    55,16
  623.     dc.l    NULL
  624.     dc.l    ITextText3
  625.     dc.l    IText4
  626. ITextText3:
  627.     dc.b    'I caught a GURU!',0
  628.     cnop 0,2
  629. IText4:
  630.     dc.b    3,0,RP_JAM1,0
  631.     dc.w    20,28
  632.     dc.l    TAttr
  633.     dc.l    ITextText4
  634.     dc.l    NULL
  635. ITextText4:
  636.     dc.b    'Should I make a SnapShot?',0
  637.     cnop 0,2
  638. IText5:
  639.     dc.b    3,0,RP_JAM1,0
  640.     dc.w    6,4
  641.     dc.l    TAttr
  642.     dc.l    ITextText5
  643.     dc.l    NULL
  644. ITextText5:
  645.     dc.b    'YES',0
  646.     cnop 0,2
  647. IText6:
  648.     dc.b    3,0,RP_JAM1,0
  649.     dc.w    7,4
  650.     dc.l    TAttr
  651.     dc.l    ITextText6
  652.     dc.l    NULL
  653. ITextText6:
  654.     dc.b    'NO',0
  655.     cnop 0,2
  656.  
  657. *--------------------------------------------------------------------------
  658. * New IFF chunk format -
  659. *    PGTB = Program Traceback, header for chunk
  660. *    FAIL = reason for and environment of crash
  661. *    REGS = registers at time of crash, including PC and CCR
  662. *    VERS = version, revision, name of this program
  663. *    STAK = ENTIRE stack at time of crash or, alternately,
  664. *        the top and bottom 4k if the stack used is > 8k
  665. *    UDAT = optional user data dump (if _ONGURU is set to a
  666. *        function pointer in the user's program)
  667. *--------------------------------------------------------------------------
  668.  
  669. PGTB        dc.b    'PGTB'
  670. Length        dc.l    0        ; length of chunk (in longwords)
  671.  
  672. subFAIL     dc.b    'FAIL'
  673. FAILlen     dc.l    9
  674. NameLen     dc.l    0        ; length of program name
  675. chunk_len_1    equ    *-PGTB
  676. Environment    dc.l    0        ; CPU (, Math)
  677. VBlankFreq    dc.l    0        ;    PAL = 50, NTSC = 60 (approx.)
  678. PowerSupFreq    dc.l    0        ; Europe = 50,    USA = 60 (approx.)
  679. Starter     dc.l    0        ; 0 = WB, -1 = CLI
  680. GURUNum     dc.l    0        ; cause of crash (GURU #)
  681. SegCount    dc.l    1        ; # hunks in seglist
  682. chunk_len_2    equ    *-Environment
  683.  
  684. subREGS     dc.b    'REGS'          ; REGS - register storage field
  685. REGSlen     dc.l    18
  686. GURUAddr    dc.l    0        ; PC at time of crash
  687. Flags        dc.l    0        ; Condition Code Register (CCR)
  688. DDump        dc.l    0,0,0,0,0,0,0,0 ; data registers
  689. ADump        dc.l    0,0,0,0,0,0,0    ; address registers
  690. A7Store     dc.l    0
  691.  
  692. subVERS     dc.b    'VERS'          ; VERS - program version field
  693.          dc.l    5
  694.          dc.l    VERSION     ; version #
  695.         dc.l    REVISION    ; revision #
  696.         dc.l    2        ; length of name of program
  697.         dc.b    'catch.o',0     ; name
  698.  
  699. subSTAK     dc.b    'STAK'          ; STAK - stack field
  700. STAKlen     dc.l    4
  701. Type        dc.l    0        ; 0 = Info
  702. StackTop    dc.l    0        ; top of stack pointer
  703. StackPtr    dc.l    0        ; current Stack Pointer
  704. StackLen    dc.l    0        ; # bytes used on stack
  705. chunk_len_3    equ    *-subREGS
  706.  
  707. STAK2        dc.b    'STAK'
  708. s2len        dc.l    1        ; length of subtype
  709.         dc.l    1        ; 1 = whole stack
  710. STAK2len    equ    *-STAK2
  711.  
  712. STAK3        dc.b    'STAK'
  713.         dc.l    1025
  714.         dc.l    2        ; 2 = top 4k of stack
  715. STAK3len    equ    *-STAK3
  716.  
  717. STAK4        dc.b    'STAK'
  718.         dc.l    1025
  719.         dc.l    3        ; 3 = bottom 4k of stack
  720. STAK4len    equ    *-STAK4
  721.  
  722. UDAT        dc.b    'UDAT'
  723.         dc.l    0
  724. UDATlen        equ    *-UDAT
  725.     END
  726.  
  727.